﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using DotNetNuke;
using DotNetNuke.Data;
using DotNetNuke.Common;
using System.Collections;
using DotNetNuke.Common.Utilities;
namespace TwentyTech.ToolTips
{
    public class ToolTipController
    {
        public static ToolTipInstance GetToolTipInstance(int moduleId)
        {
            ToolTipInstance instance;
            string content = (string)DataProvider.Instance().ExecuteScalar("TwentyTech_ToolTips_Get_ToolTipInstance", moduleId);
            instance = new ToolTipInstance(content);

            IDataReader dr = DataProvider.Instance().ExecuteReader("TwentyTech_ToolTips_Get_ToolTips",moduleId);

            instance.ToolTips = (ToolTipInfo[])CBO.FillCollection<ToolTipInfo>(dr).ToArray();


            return instance;

        }

        public static void SaveContent(int moduleId,string content)
        {
            DataProvider.Instance().ExecuteNonQuery("TwentyTech_ToolTips_Update_Content", moduleId, content);
        }

        public static int AddToolTip(int moduleId, string content)
        {
            return DataProvider.Instance().ExecuteScalar<int>("TwentyTech_ToolTips_Update_ToolTip", null, moduleId, content);
        }

        public static int UpdateToolTip(int tooltipId, int moduleId, string content)
        {
            return DataProvider.Instance().ExecuteScalar<int>("TwentyTech_ToolTips_Update_ToolTip", tooltipId, moduleId, content);
        }

        public static void DeleteToolTip(int tooltipId)
        {
            DataProvider.Instance().ExecuteScalar<int>("TwentyTech_ToolTips_Delete_ToolTip", tooltipId);
        }

    }
}